package com.itheima.exception;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo04 {

    public static void main(String[] args) {

        //method1();
       // method2();
        int i= 0;//ArithmeticException
        try {
            System.out.println("A");
            int[] arr= {11,22,33};
            System.out.println(arr[5]);
            i = 1/0;
            System.out.println("B");
        } catch (NullPointerException e) {
            System.out.println("C");
            System.out.println("发生了空指针异常");
        }catch (RuntimeException e) {
            System.out.println("E");
          System.out.println("发生了数学异常");
        }
        //System.out.println(i);
        System.out.println("D");

    }

    public static void method2() {
        String s="1991-10/01";
        Date parse = null;
        try {
            parse = new SimpleDateFormat("").parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println(parse);
    }

    public static void method1() {
        int[] arr=null;
        try{
            System.out.println(arr[0]);
        }catch (NullPointerException e){
            System.out.println("嘿,逮住你了");
            System.out.println(e);
        }
        System.out.println("看看我执行了吗");
    }
}
